<template>
    <div class="all">
      <div class="all1">
        <header>
          <div class="div">
            <img src="../../assets/fff返回.png" @click="back()" alt="">
            <span class="solid" @click="back()">返回</span>
          </div>
          <div class="div">
            <span>医生详情</span>
          </div>
          <div class="div"></div>
        </header>
        <div class="boxInfo">
          <ul class="doctorInfoUL">
            <li class="InfoLeft">
              <img v-if="doctorInfo.PHOTO" :src="doctorInfo.PHOTO" class="photo" alt="">
              <img  v-else-if="Number(doctorInfo.SEX) == 1" src="../../assets/男医生@2x.png" class="photo" alt="">
              <img  v-else-if="Number( doctorInfo.SEX )== 2" src="../../assets/女医生@2x.png" class="photo" alt="">
              <span
                style="background: rgba(0, 0, 0, 0.15);
                color: #fff;
                font-size: 11px;
                white-space: nowrap;
padding: 3px 5px;
border-radius: 2px;">{{doctorInfo.dict_name}}</span>
            </li>
            <li class="InfoRight">
              <p class="name">
                <a >{{doctorInfo.NICK_NAME}}</a>
                <a style="margin: auto 5px"> |</a>
                <a style="font-size: 13px;font-weight: 500;display: flex;align-items: center">{{doctorInfo.MAJOR}}</a>
                <a style="margin: auto 5px"> |</a>
                <a style="font-size: 13px;font-weight: 500!important;">{{doctorInfo.DEPART}}</a>
              </p>
              <p class="hospital">{{doctorInfo.HOSPITAL_NAME}}
                <span class="biaoqian">{{doctorInfo.GRADE}}</span>
              </p>
            </li>
          </ul>
          <div class="divMenu">
            <ul>
              <li>{{doctorInfo.jiezhenCount}}</li>
              <li>接诊率</li>
            </ul>
            <ul>
              <li>{{doctorInfo.haopingLv}}</li>
              <li>好评率</li>
            </ul>
            <ul>
              <li>{{doctorInfo.zixunCount}}</li>
              <li>咨询量</li>
            </ul>
          </div>
        </div>
      <div class="goodDivAll">
          <div class="goodDiv">
            <img src="../../assets/图文擅长.png" class="tuwenImg" alt="">
            <span class="goodText">
              <a style="">擅长：</a>
              <a >
                {{doctorInfo.Goodat}}
              </a>
            </span>
          </div>
          <div class="goodDiv">
            <img src="../../assets/图文介绍.png" class="tuwenImg" alt="">
            <span class="goodText">
              <a >介绍：</a>
              <a >{{doctorInfo.INTRODUCE}}</a>
            </span>
          </div>
        </div>
      </div>
      <div class="title">
          <a class="hengGang"></a>
          执业点
      </div>
      <div style="margin-bottom: 10px">
        <span class="zhiYe">
          {{doctorInfo.HOSPITAL_NAME}}
        </span>
      </div>
      <div class="title"  v-if="doctorInfo.dPack && doctorInfo.dPack.length > 0">
        <a class="hengGang"></a>
        项目组合列表
      </div>
<!--    -->
      <div class="box"   @click="lookHis(item)"   v-for="(item, index) in doctorInfo.dPack" :key="index">
        <div class="box_header">
            <span style="display: flex;align-items: center">
               <img src="../../assets/服务包.png" alt="">
              {{item.package_name}}
            </span>
            <span style="display: flex;flex-direction: column">
             <a style="color: #E3170D;font-size: 13px">￥{{item.rebate_amount}}</a>
             <s style="color: #999;font-size: 11px" v-show="item.rebate_amount !== item.standard_amount">￥{{item.standard_amount}}</s>
           </span>
        </div>
        <div class="box_content">
          <p>可购买时间：{{item.buy_start_date}} 至 {{item.buy_end_date}}</p>
          <p>首次使用时间：{{item.use_start_date}} 至 {{item.use_end_date}}</p>
          <p>项目组合购买后使用有效期：{{item.val_days}}天</p>
          <p class="textContent">项目组合内容：
            {{item.itemList[0].item_id}} {{item.itemList[0].times}}次...
          </p>
        </div>
      </div>
      <div class="title" v-show="Active === 1" >
        <a class="hengGang"></a>
        申请说明
      </div>
      <div v-show="Active === 1" style="padding: 5px 10px;box-sizing: border-box;font-size: 15px;line-height: 1.7;margin-bottom: 50px">
        {{req_msg ? req_msg : '暂无申请说明'}}
      </div>
      <div class="bottom" v-show="Active === 1">
        <div style="color: #E3170D"  @click.stop="refuse()">拒绝</div>
        <div style="color: #1da4f2" @click.stop="agree()">同意</div>
      </div>
      <van-dialog v-model="agreeShow"
                  width="80%"
                  confirm-button-color="#1da4f2"
                  title="您确认同意该成员的申请加入吗？"
                  @confirm="agreeConfirm()"
                  show-cancel-button>
      </van-dialog>
      <van-dialog v-model="refuseShow"
                  width="80%"
                  confirm-button-color="#1da4f2"
                  title="您确认拒绝该成员的申请加入吗？"
                  @confirm="refuseConfirm()"
                  show-cancel-button>
      </van-dialog>
    </div>
</template>

<script>
import {Toast} from 'vant'
export default {
  name: 'DoctorInfo',
  data () {
    return {
      doctorInfo: [],
      doc_user_id: this.$route.query.doc_user_id,
      Active: Number(this.$route.query.Active),
      id: this.$route.query.team_id,
      agreeShow: false,
      refuseShow: false,
      req_msg: ''
    }
  },
  mounted () {
    // 获取医生详细信息
    this.getDocInfo()
    this.req_msg = sessionStorage.getItem('req_msg')
    if (sessionStorage.getItem('req_msg') == 'null' || sessionStorage.getItem('req_msg') == 'undefiend') {
      this.req_msg = ''
    }
  },
  methods: {
    refuseConfirm () {
      this.$http.NoTeamRequest({team_id: this.id, doc_user_id: this.doc_user_id})
        .then(res => {
          console.log(res)
          if (res.data.status === 'success') {
            Toast('您已拒绝该成员的申请加入')
            this.back()
          } else {
            Toast(res.data.msg)
          }
        })
        .catch(err => {
          console.log(err)
        })
    },
    refuse () {
      this.refuseShow = true
    },
    // 同意加入按钮
    agree () {
      this.agreeShow = true
    },
    // 同意 加入接口
    agreeConfirm () {
      this.$http.agreeTeamRequest({team_id: this.id, doc_user_id: this.doc_user_id})
        .then(res => {
          console.log(res)
          if (res.data.status === 'success') {
            Toast('您已同意该成员的申请加入')
            this.back()
          }
        })
        .catch(err => {
          console.log(err)
        })
    },
    // 获取医生详细信息
    getDocInfo () {
      this.$http.minidoctorDetail({doc_user_id: this.doc_user_id})
        .then(res => {
          console.log(res)
          if (res.data.status === 'success') {
            this.doctorInfo = res.data.data
          }
        })
        .catch(err => {
          console.log(err)
        })
    },
    // 查看历史记录
    lookHis (item) {
      this.$router.push({path: '/keepServicePack', query: {id: item.id, isEdit: 0}})
    },
    back () {
      this.$router.history.go(-1)
    }
  },
  destroyed () {
    sessionStorage.removeItem('req_msg')
  }
}
</script>

<style scoped>
  .all{
    width: 100%;
    height: 100%;
    overflow: auto;
    background: #FAF9FE;
  }
  .all1{
    width: 100%;
    /*height: 100%;*/
    /*overflow: auto;*/
    /*background: url("../../assets/homeBackground.png") no-repeat;*/
    /*background-position: top;*/
    /*background-size: 100% 30%;*/
    background: #1DA4F2;
  }
  header{
    width: 100%;
    height: 44px;
    display: flex;
    align-items: center;
    font-family: "PingFang SC";
    color: white;
    position: sticky;
    top: 0;
    background: #1da5f2;
    z-index: 99;
  }
  .div{
    width: 33%;
    font-size: 15px;
    font-weight: bold;
    display: flex;
    align-items: center;
  }
  .div:nth-child(1) img{
    width: 7px;
    height: 13px;
    margin: 0 5px 0 15px;
  }
  .div:nth-child(2){
    justify-content: center;
  }
  .boxInfo{
    /*width: 90%;*/
    margin: 0 auto;
    border-radius: 10px;
    /*overflow: hidden;*/
    /*position: relative;*/
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    padding: 0 15px;
    box-sizing: border-box;
  }
  .doctorInfoUL{
    display: flex;
  }
  .InfoLeft{
    width: 20%;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .InfoLeft span{
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .photo{
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    /*position: absolute;*/
    /*top: -30px;*/
    /*left: 40%;*/
  }
  .InfoRight{
    width: 80%;
    display: flex;
    flex-direction: column;
    /*justify-content: space-around;*/
  }
  .InfoRight p {
    margin-top: 10px;
  }
  .box p{
    height: 30px;
    display: flex;
    align-items: center;
    /*justify-content: center;*/
    color: white;
  }
  .biaoqian{
    /*padding: 2px 8px;*/
    min-width: 44px;
    height: 18px;
    border-radius: 15px;
    box-sizing: border-box;
    /*background: #fff;*/
    background: transparent;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid #fff;
    font-size: 11px;
    margin-left: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .zhiYe{
    padding: 5px 8px;
    border-radius: 5px;
    box-sizing: border-box;
    color: #1DA4F2;
    font-size: 13px;
    margin-left: 15px;
    border: 1px solid #1DA4F2;
  }
  .name{
    font-size: 15px;
    font-family: PingFang SC;
    font-weight: bold;
    color: #FFFFFF;
    display: flex;
    align-items: center;
  }
  .hospital{
    font-size: 13px;
    font-family: PingFang SC;
    font-weight: 500;
    color: #FFFFFF;
    display: flex;
    align-items: center;
  }
  .divMenu{
    width: 100%;
    display: flex;
    margin: 10px auto;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
  }
  .divMenu ul{
    width: 33%;
    padding: 10px 0;
    box-sizing: border-box;
  }
  .divMenu ul li:nth-child(1) {
    font-size: 17px;
    font-family: PingFang SC;
    font-weight: bold;
    color: #fff;
  }
  .divMenu ul li{
    width: 100%;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 13px;
  }
  .goodDivAll{
    background: white;
    padding: 10px 0;
    box-sizing: border-box;
    border-radius: 10px 10px 0 0;
  }
  .goodDiv{
    padding: 0 15px;
    box-sizing: border-box;
    margin-top: 8px;
    font-size: 15px;
    font-family: PingFang SC;
    font-weight: 500;
    line-height: 25px;
    display: flex;
    /*align-items: center;*/
  }
  .tuwenImg{
    width: 22px;
    height: 22px;
    margin-right: 3px;
  }
  .goodText{
    display: flex;
  }
  .goodText a{
    display: block;
  }
  .goodText a:nth-child(1){
    white-space: nowrap;
  }
  .title{
    width: 100%;
    height: 44px;
    display: flex;
    align-items: center;
    padding: 0 15px;
    box-sizing: border-box;
    font-size: 17px;
    font-family: PingFang SC;
    font-weight: bold;
  }
  .hengGang{
    display: block;
    width: 2px;
    border-radius: 1px;
    height: 15px;
    background: #1DA4F2;
    margin-right: 5px;
  }

  .box{
    width: 92%;
    box-shadow: 0px 5px 20px 0px rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    margin: 10px auto;
    padding: 5px 10px;
    box-sizing: border-box;
    background: white;
  }
  .box_header{
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 15px;
    font-family: PingFang SC;
    font-weight: 500;
    color: #333333;
  }
  .box_header img{
    width: 18px;
    height: 18px;
    margin-right: 10px;
  }
  .box_content p {
    height: 25px;
    line-height: 25px;
    display: flex;
    align-items: center;
    font-size: 13px;
    font-family: PingFang SC;
    font-weight: 500;
    color: #666666;
  }
  .textContent{
    width: 80%;
    display: block !important;
    /*//单行*/
    overflow: hidden;
    text-overflow:ellipsis;
    white-space: nowrap;
  }
  .bottom{
    position: fixed;
    bottom: 50px;
    width: 100%;
    display: flex;
    align-items: center;
    height: 49px;
    background: #FFFFFF;
  }
  .bottom div{
    width: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .bottom div:first-child{
    border-right: 1px solid #E5E5E5;
  }
</style>
